package com.example.demo.config;


import com.example.demo.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;

    public WebConfig() {
        System.out.println("WebConfig initialized...");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
               .addPathPatterns("/news/**");
////                .addPathPatterns("/**")
////                .excludePathPatterns("/user/**") // 不拦截user下面的所有接口
////                .excludePathPatterns("/*.html") //不拦截以html结尾的资源访问
////                .excludePathPatterns("/*.css")
////                .excludePathPatterns("/*.js")
////                .excludePathPatterns("/*.png");
    }
}